package com.ruoyi.contract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.contract.domain.reminderVo.ContractReminderVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contract.domain.ExpirationReminder;
import com.ruoyi.contract.service.IExpirationReminderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合同到期提醒Controller
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/contract/ExpirationReminder")
public class ExpirationReminderController extends BaseController
{
    @Autowired
    private IExpirationReminderService expirationReminderService;

    /**
     * 查询合同到期提醒列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminder:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpirationReminder expirationReminder)
    {
        startPage();
        List<ContractReminderVo> list = expirationReminderService.selectExpirationReminderList(expirationReminder);
        return getDataTable(list);
    }

    /**
     * 导出合同到期提醒列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminder:export')")
    @Log(title = "合同到期提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpirationReminder expirationReminder)
    {
        List<ContractReminderVo> list = expirationReminderService.selectExpirationReminderList(expirationReminder);
        ExcelUtil<ContractReminderVo> util = new ExcelUtil<ContractReminderVo>(ContractReminderVo.class);
        util.exportExcel(response, list, "合同到期提醒数据");
    }

    /**
     * 获取合同到期提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminder:query')")
    @GetMapping(value = "/{expirationReminderId}")
    public AjaxResult getInfo(@PathVariable("expirationReminderId") Long expirationReminderId)
    {
        return success(expirationReminderService.selectExpirationReminderByExpirationReminderId(expirationReminderId));
    }

    /**
     * 新增合同到期提醒
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminder:add')")
    @Log(title = "合同到期提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpirationReminder expirationReminder)
    {
        return toAjax(expirationReminderService.insertExpirationReminder(expirationReminder));
    }

    /**
     * 修改合同到期提醒
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminder:edit')")
    @Log(title = "合同到期提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpirationReminder expirationReminder)
    {
        return toAjax(expirationReminderService.updateExpirationReminder(expirationReminder));
    }

    /**
     * 删除合同到期提醒
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminder:remove')")
    @Log(title = "合同到期提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{expirationReminderIds}")
    public AjaxResult remove(@PathVariable Long[] expirationReminderIds)
    {
        return toAjax(expirationReminderService.deleteExpirationReminderByExpirationReminderIds(expirationReminderIds));
    }
}
